package com.jiantong.work.impl.manager;

import com.jiantong.work.impl.dao.CertNumberDao;
import com.jiantong.work.impl.dao.IssuanceTableDao;
import com.jiantong.work.model.CertNumber;
import com.jiantong.work.model.IssuanceTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by mz on 16/5/17.
 *
 */
@Component
public class AnimalCertificateManager {

    private final IssuanceTableDao issuanceTableDao;
    private final CertNumberDao certNumberDao;

    @Autowired
    public AnimalCertificateManager(IssuanceTableDao issuanceTableDao,
                                    CertNumberDao certNumberDao){
        this.issuanceTableDao = issuanceTableDao;
        this.certNumberDao = certNumberDao;
    }

    @Transactional
    public IssuanceTable handle(IssuanceTable issuanceTable,
                                CertNumber certNumber){
        issuanceTableDao.create(issuanceTable);

        certNumberDao.update(certNumber);

        return issuanceTable;
    }
}
